'''生成器
    genterator
'''

# list1 = []
# for i in range(2,10001,2):
#     list1.append(i)
# print(list1)
import time
import sys

# time.perf_counter()
# list1 = [x for x in range(2,10000001,2)]
# costTime = time.perf_counter()
# print("创建列表耗时：%g"%costTime)
# print("创建列表内存开销：%g"%sys.getsizeof(list1))



time.perf_counter()
g1 = (x for x in range(2,10000001,2))
costTime1 = time.perf_counter()
print("创建生成器耗时：%g"%costTime1)
print("创建生成器内存开销：%g"%sys.getsizeof(g1))

# g1 = (x for x in range(2,10000001,2))
# print(type(g1))
for i in g1:
    print(i)
# list2 = [x for x in range(1,11) if x % 2 == 0]
# print(list2)
#
# list3 = [a + b for a in "123" for b in "xyz"]
# print(list3)
